﻿//using System;
//using System.Runtime.InteropServices;

//namespace Mbs.Messaging.Imp
//{
//    [Serializable]
//    [ComVisible(true)]
//    internal class WeakReference<T> : WeakReference where T : class
//    {
//        protected int hashCode = -1;
//        public WeakReference() : base(null) { }
//        public WeakReference(T target) : base(target) { hashCode = target.GetHashCode(); }
//        public WeakReference(T target, bool trackResurrection) : base(target, trackResurrection) { hashCode = target.GetHashCode(); }
//        public WeakReference(object target)
//            : base(target)
//        {
            
//        }
//        public WeakReference(object target, bool trackResurrection)
//            : base(target, trackResurrection)
//        {
            
//        }
//        protected WeakReference(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
//            : base(info, context)
//        {
            
//        }
                                                                                                                                     

//        public new T Target
//        {
//            get
//            {
//                return base.Target as T;
//            }
//            set
//            {
//                base.Target = value;
//            }
//        }

//        public override int GetHashCode()
//        {
//            return hashCode;
//        }

//        public override bool Equals(object o)
//        {
//            WeakReference<T> other = o as WeakReference<T>;
//            if (other == null)
//            {
//                return false;
//            }
//            T item = this.Target;
//            if (item == null)
//            {
//                return false;
//            }

//            return ((this.hashCode == other.hashCode) && object.Equals(item, other.Target));
//        }

//        public static implicit operator T(WeakReference<T> o)
//        {

//            if (o != null && o.Target != null)
//                return o.Target;
//            return null;
//        }

//        public static implicit operator WeakReference<T>(T target)
//        {
//            return new WeakReference<T>(target);
//        }
//    }
//}
